Skip to content

Conversation

@dnikitop
Copy link

@dnikitop dnikitop commented Oct 14, 2024

Public API Changes

Description

We use rclnodejs to provide type information on ros message types only. This is so we can run without having a ros installation. The current exported types to have constant values. This allows us to define type enums for constants.

Changes

  export interface MsgFwForkData {
    timestamp: builtin_interfaces.msg.Time;
    timestamp_us: number;
    position: number;
    status: number;
  }
  export interface MsgFwForkDataConstructor {
    readonly STATUS_NONE: number;
    readonly STATUS_STOPPED: number;
    new(other?: MsgFwForkData): MsgFwForkData;
  }

to

  export interface MsgFwForkData {
    timestamp: builtin_interfaces.msg.Time;
    timestamp_us: number;
    position: number;
    status: number;
  }
   export enum MsgFwForkDataConstants{
    STATUS_NONE = 1,
    STATUS_STOPPED = 2,
  }
  export interface MsgFwForkDataConstructor {
    readonly STATUS_NONE: MsgFwForkDataConstants.STATUS_NONE;
    readonly STATUS_STOPPED: MsgFwForkDataConstants.STATUS_STOPPED;
    new(other?: MsgFwForkData): MsgFwForkData;
  }

Dimitri Nikitopoulos added 2 commits October 14, 2024 11:10
const type = rosMsgInterface.type();
const msgName = type.interfaceName;

fs.writeSync(fd, ` export interface ${msgName}Constants {\n`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be enum here?

for (const constant of rosMsgInterface.ROSMessageDef.constants) {
const constantType = primitiveType2JSName(constant.type);
fs.writeSync(fd, ` readonly ${constant.name}: ${constantType};\n`);
s.writeSync(fd, ` readonly ${constant.name}: ${msgName}Constants.${constant.name};\n`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=>fs.writeSync

@dnikitop dnikitop closed this Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants